function addZero(str){
	if(parseInt(str) < 10){
	    str = '0'+str;
	}
	return str;
}

const getMyDate = ()=>{
	 var oDate = new  Date(),
	    oYear = oDate.getFullYear(),
	    oMonth = oDate.getMonth()+1,
	    oDay = oDate.getDate(),
	    oHour = oDate.getHours(),
	    oMin = oDate.getMinutes(),
	    oSen = oDate.getSeconds(),
	    oTime = oYear +'-'+ addZero(oMonth) +'-'+ addZero(oDay);
	return oTime;
}


const getDateH = ()=>{
	 var oDate = new  Date(),
	    oYear = oDate.getFullYear(),
	    oMonth = oDate.getMonth()+1,
	    oDay = oDate.getDate(),
	    oHour = oDate.getHours(),
	    oMin = oDate.getMinutes(),
	    oSen = oDate.getSeconds(),
	    oTime = addZero(oHour);
	return oTime;
}

const jsonDateFormat = (jsonDate) =>{
	//json日期格式转换为正常格式
	try {
	    var date = new Date(Date.parse(jsonDate.replace(/-/g, "/")));
	    var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
	    var day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
	    var hours = date.getHours();
	    var minutes = date.getMinutes();
	    var seconds = date.getSeconds();
	    var milliseconds = date.getMilliseconds();
		//+ " " + hours + ":" + minutes + ":" + seconds + "." + milliseconds
	    return date.getFullYear() + "-" + month + "-" + day;
	} catch (ex) {
	    return "";
	}
}

const timestampToTime = (timestamp)=> {
    var Y,M,D="";
    var date = new Date(timestamp );//时间戳为10位需*1000，时间戳为13位的话不需乘1000
    Y = date.getFullYear() + '-';
    M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
    D = date.getDate() + ' ';
    return Y+M+D;//时分秒可以根据自己的需求加上
 }

export default{
	getMyDate,
	jsonDateFormat,
	getDateH,
	timestampToTime,
}